package fauxman.states;

import fauxman.DynamicElements.Ghost;
import fauxman.model.WorldModel;
import fauxman.utilities.ActionUtil;
import fauxman.utilities.SpriteUtil;

public class EatenGhostState extends GhostState {
	private static EatenGhostState instance;
	private static int[] target = {13, 11};
	
	private EatenGhostState(){
	}
	
	public static EatenGhostState getInstance(){
		if (instance==null)
			instance = new EatenGhostState();
		return instance;
	}
	
	public void setAppearance(int appearanceID, Ghost g) {
		g.setAppearance(SpriteUtil.getEatenSprite(appearanceID));
	}
	
	//Above left section of door
	public int[] getTarget(WorldModel model, Ghost g) {
		return target;
	}
	@Override
	public void reactToCurrentDiscretePosition(WorldModel model, Ghost g){
		if(g.getDiscretePosition().x == target[0] && g.getDiscretePosition().y == target[1]){
			System.out.println("Ghost \""+ g + "\" changing to EnteringGhostHouseState");
			g.changeState(g.getEnteringGhostHouseState());
			g.setNextDirection(ActionUtil.SOUTH);
			//set reversal tile to Entering house states target
			//since Entering House State doesn't model (the first argument of getTarget) we pass it null
			g.setReversalBlock(g.getEnteringGhostHouseState().getTarget(null, g)[0], g.getEnteringGhostHouseState().getTarget(null, g)[1]);
		}
	}
}
